package com.blueocean_health.care.management.em;

import com.blueocean_health.care.management.common.base.string.StringUtils;

/**
 * @Author Liuchengxiu
 * @Date 2017/8/22 11:50
 */


public enum TransTypeEnum {

    _1("1", "现金"),
    _2("2", "POS机"),
    _3("3", "银行转账"),
    _4("4", "微信和支付宝转账"),
    _5("5", "微信"),
    _6("6", "支付宝"),;


    private String key;
    private String val;

    TransTypeEnum(String key, String val) {
        this.key = key;
        this.val = val;
    }

    public String getVal() {
        return val;
    }

    public String getKey() {
        return key;
    }
    /**
	 * 根据key值查value
	 * 
	 * @param value
	 * @return
	 */
	public static String ValOfKey(String key) {
		if (!StringUtils.isEmpty(key)) {
			TransTypeEnum[] businessModeEnums = values();
			for (TransTypeEnum businessModeEnum : businessModeEnums) {
				if (businessModeEnum.getKey().equals(key)) {
					return businessModeEnum.getVal();
				}
			}
		}
		return null;
	}
	
	/**
	 * 根据value值查key
	 * 
	 * @param value
	 * @return
	 */
	public static String KeyOfValue(String value) {
		if (!StringUtils.isEmpty(value)) {
			TransTypeEnum[] businessModeEnums = values();
			for (TransTypeEnum businessModeEnum : businessModeEnums) {
				if (businessModeEnum.getVal().equals(value)) {
					return businessModeEnum.getKey();
				}
			}
		}
		return null;
	}
	
}
